from django.contrib.auth.models import Permission, Group

from django.contrib.auth.models import Permission, ContentType
from rest_framework.pagination import PageNumberPagination
from rest_framework.response import Response
from rest_framework.viewsets import ModelViewSet

from sadmin.serializersss.permission_serializers import PermissionSerialzier, GroupSerializer
from sadmin.utils import Mypage


class PermissionView(ModelViewSet):
    serializer_class = PermissionSerialzier
    queryset = Permission.objects.all()
    pagination_class = Mypage
    def get_simple(self,request):
        queryset = Permission.objects.all()
        data = PermissionSerialzier(queryset,many=True)
        return Response(data.data)



#
class GroupViewSet(ModelViewSet):
    queryset = Group.objects.all()
    serializer_class = GroupSerializer
    pagination_class = Mypage

    def notpage(self,request,):
        queryset = Group.objects.all()
        data = GroupSerializer(queryset,many=True)
        return Response(data.data)
    # def get_paginated_response(self, data):
    #
    #     print(self,data)



    # def simple(self, reqeust):
    #     pers = Group.objects.all()
    #     ser = GroupSerializer(pers, many=True)
    #     return Response(ser.data)